Skip to content

Support Mooncake 0.6 forward mode in find_alpha rules - #480

Merged
shravanngoswamii merged 4 commits into
mainfrom
compat-mooncake-0.6
Jun 19, 2026
Merged

Support Mooncake 0.6 forward mode in find_alpha rules#480
shravanngoswamii merged 4 commits into
mainfrom
compat-mooncake-0.6

Conversation

@yebai

@yebai yebai commented Jun 18, 2026

Copy link
Copy Markdown
Member

Mooncake 0.6 reworks batched forward AD around Lifted/NDual and routes prepare_derivative_cache (used by AutoMooncakeForward) through build_frule. Add frule!!(::Lifted, ...) rules for find_alpha (float and integer third argument), gated behind pkgversion(Mooncake) >= v"0.6", keeping the existing Mooncake.Dual rules for 0.5.

Under 0.6, these Lifted rules intercept find_alpha as a primitive, so the batched pass never enters its body. Under 0.5 the batched (Nfwd) pass instead propagates NDuals straight through find_alpha, tripping on ceil(::Int, ::NDual) inside the root-finder; the find_alpha(::NDual, ...) short-circuit methods fix that and are therefore gated to < v"0.6" (verified redundant on 0.6, required on 0.5).

This unbreaks the AutoMooncakeForward PlanarLayer-inverse integration case, so drop its @test_broken marker. Bump Mooncake compat to allow 0.6.

Note: Mooncake 0.6 is not yet released. This PR fix Mooncake 0.6 compatibility in a non-breaking way.

Mooncake 0.6 reworks batched forward AD around `Lifted`/`NDual` and routes
`prepare_derivative_cache` (used by `AutoMooncakeForward`) through `build_frule`.
Add `frule!!(::Lifted, ...)` rules for `find_alpha` (float and integer third
argument), gated behind `pkgversion(Mooncake) >= v"0.6"`, keeping the existing
`Mooncake.Dual` rules for 0.5.

Under 0.6 these `Lifted` rules intercept `find_alpha` as a primitive, so the
batched pass never enters its body. Under 0.5 the batched (Nfwd) pass instead
propagates `NDual`s straight through `find_alpha`, tripping on
`ceil(::Int, ::NDual)` inside the root-finder; the `find_alpha(::NDual, ...)`
short-circuit methods fix that and are therefore gated to `< v"0.6"` (verified
redundant on 0.6, required on 0.5).

This un-breaks the `AutoMooncakeForward` PlanarLayer-inverse integration case,
so drop its `@test_broken` marker. Bump Mooncake compat to allow 0.6.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Bijectors.jl documentation for PR #480 is available at:
https://TuringLang.github.io/Bijectors.jl/previews/PR480/

@yebai
yebai requested a review from shravanngoswamii June 18, 2026 13:07
Comment thread ext/BijectorsMooncakeExt.jl
Comment thread Project.toml Outdated
@shravanngoswamii

shravanngoswamii commented Jun 19, 2026

Copy link
Copy Markdown
Member

Note: Mooncake 0.6 is not yet released. This PR fix Mooncake 0.6 compatibility in a non-breaking way.

Should we wait here until Mooncake 0.6 release?

@yebai

yebai commented Jun 19, 2026

Copy link
Copy Markdown
Member Author

Should we wait here until Mooncake 0.6 release?

Probably not, as this branch is fully compitable with 0.5, and the upcoming 0.6 is unlikely to change Lifted.

@shravanngoswamii
shravanngoswamii merged commit de1127e into main Jun 19, 2026
19 of 21 checks passed
@shravanngoswamii
shravanngoswamii deleted the compat-mooncake-0.6 branch June 19, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants